# Contributor: Michael M <mic@hael.xyz>
# Maintainer: Michael M <mic@hael.xyz>
pkgname=zydis
pkgver=4.0.0
pkgrel=0
pkgdesc="Fast and lightweight x86/x86-64 disassembler and code generation library"
url="https://zydis.re"
arch="x86 x86_64 aarch64 armhf armv7"
license="MIT"
depends_dev="zycore-dev"
makedepends="cmake samurai doxygen zycore-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/zyantific/zydis/archive/v$pkgver/zydis-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DZYAN_SYSTEM_ZYCORE=ON \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
334284bccfb6ce61cc530fd479d6278db3e4df1fb52b311acd7d21558843c9bf14e74a199cd937041d434260b65c506c07ae1a37243d2240eb9443ae5e56e000  zydis-4.0.0.tar.gz
"
